package fhp.hlhj.giantfold.activity.user

import android.support.v7.app.AppCompatActivity
import android.os.Bundle
import com.lzy.okgo.model.HttpParams
import fhp.hlhj.giantfold.BaseActivity
import fhp.hlhj.giantfold.Contents
import fhp.hlhj.giantfold.R
import fhp.hlhj.giantfold.interfaces.IBaseInterface
import fhp.hlhj.giantfold.javaBean.BaseBean
import fhp.hlhj.giantfold.presenter.ReportPresenter
import fhp.hlhj.giantfold.utils.MyUtils
import kotlinx.android.synthetic.main.activity_report_aty.*

class ReportAty : BaseActivity(), IBaseInterface {
    override fun getContentId(): Int = R.layout.activity_report_aty
    private lateinit var presenter:ReportPresenter
    override fun initListener() {
        btExit.setOnClickListener {
            finish()
        }

        btCommit.setOnClickListener {
            if (etContent.text.toString().isNotEmpty()){
                val params = HttpParams()
                params.put("user_id",Contents.userId)
                params.put("description",etContent.text.toString())
                presenter.report(params)
            }else{
                MyUtils.toast("请输入内容")
            }
        }
    }


    override fun initView() {
        presenter= ReportPresenter(this)

    }


    override fun showLoading() {
        loadingDialog.show()
    }

    override fun onResp(baseBean: BaseBean) {
        loadingDialog.dismiss()
        if (baseBean.code==200){
            MyUtils.toast("提交成功")
            finish()
        }
    }
}

